<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
	
	<!-- title -->
	
	<title>
	
		04-反射和动态代理 | 
	 
	星河
	</title>
	
	<!-- keywords,description -->
	 

	<!-- favicon -->
	
	<link rel="shortcut icon" href="/xinghe/favicon.ico">
	


	<!-- search -->
	<script>
		var searchEngine = "https://www.google.com/search?q=";
		if(typeof searchEngine == "undefined" || searchEngine == null || searchEngine == ""){
			searchEngine = "https://www.google.com/search?q=";
		}
		var homeHost = "wujun234.github.io";
		if(typeof homeHost == "undefined" || homeHost == null || homeHost == ""){
			homeHost = window.location.host;
		}
	</script>


	
<link rel="stylesheet" href="/xinghe/css/main.css">

	
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css">

	
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.17.1/build/styles/darcula.min.css">

	
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css">


	
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>

	
<script src="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>

	
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.17.1/build/highlight.min.js"></script>

	
<script src="https://cdn.jsdelivr.net/npm/jquery-pjax@2.0.1/jquery.pjax.min.js"></script>

	
<script src="/xinghe/js/main.js"></script>

	
		
<script src="https://cdn.jsdelivr.net/npm/leancloud-storage/dist/av-min.js"></script>

		
<script src="https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js"></script>

	
	
		<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
	
<meta name="generator" content="Hexo 5.4.0"></head>

<body>
	<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3efe99c287df5a1d6f0d02d187e403c1";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<header id="header">
    <a id="title" href="/xinghe/" class="logo">星河</a>

	<ul id="menu">
		
	

	

		<li class="menu-item">
			<a href="https://blog.csdn.net/springyh" class="menu-item-link" target="_blank">
				myblog
			</a>
		</li>
		<li class="menu-item">
			<a href="https://www.yuque.com/yinhehe" class="menu-item-link" target="_blank">
				语雀
			</a>
		</li>
		<li class="menu-item">
			<a href="https://gitee.com/godyh" class="menu-item-link" target="_blank">
				<i class="fa fa-github fa-2x"></i>
			</a>
		</li>
	</ul>
</header>

	
<div id="sidebar">
	<button id="sidebar-toggle" class="toggle" ><i class="fa fa-arrow-right " aria-hidden="true"></i></button>
	
	<div id="site-toc">
		<input id="search-input" class="search-input" type="search" placeholder="按回车全站搜索">
		<div id="tree">
			

			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										01.面试系列
									</a>
									
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										01.java基础
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/01.java%E5%9F%BA%E7%A1%80/01-%E6%B3%A8%E8%A7%A3/">
										01-注解
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/01.java%E5%9F%BA%E7%A1%80/02-%E6%B3%9B%E5%9E%8B/">
										02-泛型
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/01.java%E5%9F%BA%E7%A1%80/03-JavaNIO/">
										03-JavaNIO
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file active">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/01.java%E5%9F%BA%E7%A1%80/04-%E5%8F%8D%E5%B0%84%E5%92%8C%E5%8A%A8%E6%80%81%E4%BB%A3%E7%90%86/">
										04-反射和动态代理
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										02.java并发
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/01-%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%9F%BA%E7%A1%80/">
										01-多线程基础
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/02-CAS/">
										02-CAS
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/03-synchronized/">
										03-synchronized
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/04-AQS%E5%92%8CReentrantLock/">
										04-AQS和ReentrantLock
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/05-%E7%BA%BF%E7%A8%8B%E6%B1%A0/">
										05-线程池
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/06-ThreadLocal/">
										06-ThreadLocal
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/07-CountDownLatch%E5%92%8CCyclicBarrier/">
										07-CountDownLatch和CyclicBarrier
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/08-%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81Java%E5%86%85%E5%AD%98%E6%A8%A1%E5%9E%8B/">
										08-为什么需要Java内存模型
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/09-%E6%B7%B1%E5%85%A5%E6%B5%85%E5%87%BAJava%E5%86%85%E5%AD%98%E6%A8%A1%E5%9E%8B/">
										09-深入浅出Java内存模型
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										03.java容器
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/03.java%E5%AE%B9%E5%99%A8/01-List%E9%9B%86%E5%90%88/">
										01-List集合
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/03.java%E5%AE%B9%E5%99%A8/02-Map%E9%9B%86%E5%90%88/">
										02-Map集合
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/03.java%E5%AE%B9%E5%99%A8/03-Set%E9%9B%86%E5%90%88/">
										03-Set集合
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										04.java虚拟机
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/04.java%E8%99%9A%E6%8B%9F%E6%9C%BA/01-java%E7%BC%96%E8%AF%91%E5%88%B0%E6%89%A7%E8%A1%8C%E8%BF%87%E7%A8%8B/">
										01-java编译到执行过程
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/04.java%E8%99%9A%E6%8B%9F%E6%9C%BA/02-%E5%8F%8C%E4%BA%B2%E5%A7%94%E6%B4%BE%E6%9C%BA%E5%88%B6/">
										02-双亲委派机制
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/04.java%E8%99%9A%E6%8B%9F%E6%9C%BA/03-JVM%E5%86%85%E5%AD%98%E7%BB%93%E6%9E%84/">
										03-JVM内存结构
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/04.java%E8%99%9A%E6%8B%9F%E6%9C%BA/04-%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6%E6%9C%BA%E5%88%B6/">
										04-垃圾回收机制
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/04.java%E8%99%9A%E6%8B%9F%E6%9C%BA/05-CMS%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6%E6%9C%BA%E5%88%B6/">
										05-CMS垃圾回收机制
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/04.java%E8%99%9A%E6%8B%9F%E6%9C%BA/06-G1%E5%9E%83%E5%9C%BE%E6%94%B6%E9%9B%86%E5%99%A8/">
										06-G1垃圾收集器
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										05.spring
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/05.spring/01-springMVC/">
										01-springMVC
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/05.spring/02-spring%E5%9F%BA%E7%A1%80/">
										02-spring基础
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/05.spring/03-springbean%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/">
										03-springbean生命周期
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										06.redis
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/06.redis/01-redis%E5%9F%BA%E7%A1%80/">
										01-redis基础
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/06.redis/02-redis%E6%8C%81%E4%B9%85%E5%8C%96/">
										02-redis持久化
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/06.redis/03-redis%E4%B8%BB%E4%BB%8E%E6%9E%B6%E6%9E%84/">
										03-redis主从架构
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/06.redis/04-redis%E5%88%86%E7%89%87%E9%9B%86%E7%BE%A4/">
										04-redis分片集群
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										07.消息队列
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/07.%E6%B6%88%E6%81%AF%E9%98%9F%E5%88%97/01-kafka%E5%9F%BA%E7%A1%80/">
										01-kafka基础
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/07.%E6%B6%88%E6%81%AF%E9%98%9F%E5%88%97/02-kafka%E8%80%83%E8%99%91%E7%9A%84%E9%97%AE%E9%A2%98/">
										02-kafka考虑的问题
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										08.mysql
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/08.mysql/01-mysql%E7%B4%A2%E5%BC%95/">
										01-mysql索引
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/08.mysql/02-mysql%E4%BA%8B%E5%8A%A1%E5%92%8C%E9%94%81%E6%9C%BA%E5%88%B6%E5%92%8CMVCC/">
										02-mysql事务和锁机制和MVCC
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/08.mysql/03-mysql%E8%B0%83%E4%BC%98/">
										03-mysql调优
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										09.场景
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/09.%E5%9C%BA%E6%99%AF/01-%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E5%8E%BB%E9%87%8D%E5%92%8C%E5%B9%82%E7%AD%89/">
										01-如何实现去重和幂等
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/09.%E5%9C%BA%E6%99%AF/02-%E7%B3%BB%E7%BB%9F%E9%9C%80%E6%B1%82%E5%8F%98%E5%8C%96%E8%AE%BE%E8%AE%A1/">
										02-系统需求变化设计
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/09.%E5%9C%BA%E6%99%AF/03-%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">
										03-设计模式
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										02.常用工具类
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/01-CommonUtil/">
										01-CommonUtil
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/02-CookieUtils/">
										02-CookieUtils
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/03-DateUtils/">
										03-DateUtils
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/04-easyUIDataGrid%E5%AF%B9%E8%B1%A1%E8%BF%94%E5%9B%9E%E5%80%BC/">
										04-easyUIDataGrid对象返回值
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/05-Excel%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4%E5%B7%A5%E5%85%B7/">
										05-Excel阿里巴巴工具
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/06-Excel%E5%AF%BC%E5%87%BA%E5%B7%A5%E5%85%B7/">
										06-Excel导出工具
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/07-ExceptionUtil/">
										07-ExceptionUtil
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/08-FastDFSClient%E4%BD%BF%E7%94%A8/">
										08-FastDFSClient使用
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/09-FTP%E4%B8%8A%E4%BC%A0%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/">
										09-FTP上传工具使用
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/11-HttpClientUtil/">
										11-HttpClientUtil
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/12-HttpContextUtils/">
										12-HttpContextUtils
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/13-IDUtils/">
										13-IDUtils
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/14-IPUtils/">
										14-IPUtils
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/15-isBlack%E5%92%8CisEmpty%E5%8C%BA%E5%88%AB/">
										15-isBlack和isEmpty区别
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/16-jedisclient%E6%93%8D%E4%BD%9CRedis%E5%B7%A5%E5%85%B7%E7%B1%BB/">
										16-jedisclient操作Redis工具类
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/17-json%E5%B7%A5%E5%85%B7%E7%B1%BB/">
										17-json工具类
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/18-md5%E5%B7%A5%E5%85%B7%E7%B1%BB/">
										18-md5工具类
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/19-PictureResult/">
										19-PictureResult
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/20-PPTtoImage%E5%AE%9E%E7%8E%B0PPT%E8%BD%AC%E5%8C%96%E4%B8%BAPDF/">
										20-PPTtoImage实现PPT转化为PDF
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/21-ShiroUtils/">
										21-ShiroUtils
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/22-shiro%E7%9A%84md5%E5%B7%A5%E5%85%B7%E7%B1%BB/">
										22-shiro的md5工具类
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/23-spring%E5%AE%B9%E5%99%A8MD5%E5%B7%A5%E5%85%B7/">
										23-spring容器MD5工具
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/24-spring%E4%B8%AD%E8%87%AA%E5%B8%A6%E7%9A%84%E5%8A%A0%E5%AF%86%E5%B7%A5%E5%85%B7%E7%B1%BB/">
										24-spring中自带的加密工具类
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/25-TaotaoResult/">
										25-TaotaoResult
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/26-TimeUtls/">
										26-TimeUtls
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/27-%E4%BB%8E%E7%BD%91%E7%BB%9C%E4%B8%8A%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87%E8%BD%AC%E6%8D%A2%E6%88%90%E5%AD%97%E8%8A%82%E6%B5%81%E6%88%96%E8%80%85%E4%BF%9D%E5%AD%98%E5%88%B0%E6%9C%AC%E5%9C%B0/">
										27-从网络上获取图片转换成字节流或者保存到本地
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/28-%E7%9F%AD%E4%BF%A1%E5%8F%91%E9%80%81%E4%B9%8B%E4%BA%92%E8%AF%91%E6%97%A0%E7%BA%BF/">
										28-短信发送之互译无线
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/29-%E9%9D%9E%E7%A9%BA%E5%88%A4%E6%96%AD/">
										29-非空判断
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/30-%E5%88%86%E9%A1%B5%E5%B7%A5%E5%85%B7%E7%B1%BB/">
										30-分页工具类
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/31-%E8%B7%A8%E5%9F%9F%E8%AF%B7%E6%B1%82%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E5%BC%8F/">
										31-跨域请求的几种方式
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/32-%E5%89%8D%E7%AB%AF%E9%9C%80%E8%A6%81%E7%9A%84%E6%95%B0%E6%8D%AE%E8%BF%94%E5%9B%9E%E6%A0%BC%E5%BC%8F/">
										32-前端需要的数据返回格式
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/33-%E7%9B%90%E5%80%BC%E7%94%9F%E6%88%90/">
										33-盐值生成
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/34-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/">
										34-正则表达式
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/02.%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB/35-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%B7%A5%E5%85%B7%E7%B1%BB/">
										35-正则表达式工具类
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										03.springboot
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/03.springboot/01-SpringBoot%E7%BA%BF%E7%A8%8B%E6%B1%A0/">
										01-SpringBoot线程池
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
							<ul>
								<li class="directory">
									<a href="#" class="directory">
										<i class="fa fa-plus-square-o"></i>
										04.Linux
									</a>
									
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/01/04.Linux/01-Centos7%E5%BC%80%E6%94%BE%E5%8F%8A%E6%9F%A5%E7%9C%8B%E7%AB%AF%E5%8F%A3/">
										01-Centos7开放及查看端口
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/02-centos7%E5%AE%89%E8%A3%85seata/">
										02-centos7安装seata
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/03-centOS7%E5%AE%89%E8%A3%85Sentinel/">
										03-centOS7安装Sentinel
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/04-%E6%9F%A5%E7%9C%8Blinux%E5%86%85%E6%A0%B8%E7%89%88%E6%9C%AC/">
										04-查看linux内核版本
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/05-centos%E6%9B%B4%E6%94%B9yum%E6%BA%90/">
										05-centos更改yum源
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/06-Linux%E4%B8%8Bwhich%E3%80%81whereis%E3%80%81locate%E3%80%81find%E5%91%BD%E4%BB%A4%E7%9A%84%E5%8C%BA%E5%88%AB/">
										06-Linux下which、whereis、locate、find命令的区别
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/07-centos7%E5%AE%89%E8%A3%85%E4%BB%A3%E7%A0%81%E9%9B%A8cmatrix/">
										07-centos7安装代码雨cmatrix
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/08-gitblit/">
										08-gitblit
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/09-showdoc/">
										09-showdoc
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/10-CentOS7%E6%9F%A5%E7%9C%8B%E5%92%8C%E6%8E%A7%E5%88%B6%E8%BF%9B%E7%A8%8B/">
										10-CentOS7查看和控制进程
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/11-centos%E4%B8%AD%E5%A4%9A%E4%B8%AAtomcat%E9%85%8D%E7%BD%AE/">
										11-centos中多个tomcat配置
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/12-centos%E5%91%BD%E4%BB%A42021%E4%B9%8B%E5%9F%BA%E7%A1%80%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/">
										12-centos命令2021之基础环境配置
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/13-linux%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E7%A6%85%E9%81%93/">
										13-linux一键安装禅道
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/14-centos7%E5%AE%89%E8%A3%85docker/">
										14-centos7安装docker
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/15-tar%E8%A7%A3%E5%8E%8B%E5%88%B0%E6%8C%87%E5%AE%9A%E6%96%87%E4%BB%B6%E5%A4%B9/">
										15-tar解压到指定文件夹
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/16-Linux%E7%B3%BB%E7%BB%9F%E4%B8%8B%E6%9F%A5%E6%89%BE%E5%AE%89%E8%A3%85%E5%8C%85%E6%89%80%E5%9C%A8%E7%9B%AE%E5%BD%95%E7%9A%84%E5%85%AD%E7%A7%8D%E6%96%B9%E6%B3%95/">
										16-Linux系统下查找安装包所在目录的六种方法
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/17-%E6%9F%A5%E7%9C%8BCentOS%E7%89%88%E6%9C%AC%E6%96%B9%E6%B3%95/">
										17-查看CentOS版本方法
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/18-centos6%E8%AE%BE%E7%BD%AE%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8/">
										18-centos6设置开机启动
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/19-%E9%98%BF%E9%87%8C%E4%BA%91centos%E5%AE%89%E8%A3%85%E5%9B%BE%E5%BD%A2%E7%95%8C%E9%9D%A2%EF%BC%8CVNC-VIEWER%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5/">
										19-阿里云centos安装图形界面，VNC-VIEWER远程连接
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/20-centos6%E5%BF%98%E8%AE%B0%E5%AF%86%E7%A0%81/">
										20-centos6忘记密码
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/21-centos6%E5%AE%89%E8%A3%85zookeeper%E5%8D%95%E6%9C%BA%E7%89%88/">
										21-centos6安装zookeeper单机版
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/22-centos%E5%90%84%E4%B8%AA%E7%89%88%E6%9C%AC%E5%9C%B0%E5%9D%80/">
										22-centos各个版本地址
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/23-centos%E4%B8%8Byum%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3/">
										23-centos下yum命令详解
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/24-xshell%E4%BF%9D%E6%8C%81%E5%9C%A8%E7%BA%BF/">
										24-xshell保持在线
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/25-%E5%85%B3%E9%97%ADxshell6%E6%8F%90%E7%A4%BA%E9%9F%B3/">
										25-关闭xshell6提示音
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/26-centos6%E6%A8%A1%E6%9D%BF%E5%88%B6%E4%BD%9C%E6%A8%A1%E6%9D%BF/">
										26-centos6模板制作模板
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/27-Linux-yum%E5%8F%AA%E4%B8%8B%E8%BD%BD%E4%B8%8D%E5%AE%89%E8%A3%85/">
										27-Linux-yum只下载不安装
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/28-rmp%E5%8C%85%E6%9F%A5%E6%89%BE%E5%9C%B0%E5%9D%80/">
										28-rmp包查找地址
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/30-centos6%E5%AE%89%E8%A3%85oracle11g/">
										30-centos6安装oracle11g
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/31-maven%E7%A7%81%E6%9C%8D%E4%B9%8Bnexus/">
										31-maven私服之nexus
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/32-centos6%E9%85%8D%E7%BD%AE%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8%E6%96%B9%E5%BC%8F/">
										32-centos6配置开机启动方式
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/02/04.Linux/33-centos6%20%E5%AE%89%E8%A3%85redis%E9%9B%86%E7%BE%A4%E7%89%88/">
										33-centos6 安装redis集群版
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
							<ul>
								<li class="file">
									<a href="/xinghe/2021/10/03/04.Linux/35-CentOS7%E5%AE%89%E8%A3%85ElasticSearch/">
										35-CentOS7安装ElasticSearch
									</a>
								</li>
								<div class="article-toc" style="display: none;"></div>
							</ul>
			
								</li>
								
							</ul>
			
		</div>
	</div>
</div>

	<!-- 引入正文 -->
	<div id="content">
		<h1 id="article-title">

	04-反射和动态代理
</h1>
<div class="article-meta">
	
		<span>
			阅读量:<span id="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/01.java%E5%9F%BA%E7%A1%80/04-%E5%8F%8D%E5%B0%84%E5%92%8C%E5%8A%A8%E6%80%81%E4%BB%A3%E7%90%86/" class="leancloud_visitors" data-flag-title="04-反射和动态代理"></span>
		</span>
	
	<span>YH</span>
	<span>2021-10-01 16:45:05</span>
		<div id="article-categories">
    
		<span>Categories：</span>
            
    

    
		<span>Tags：</span>
            
    
		</div>

</div>

<div id="article-content">
	<meta name="referrer" content="no-referrer" />

<p><strong>面试官</strong>：今天要不来聊聊Java反射？你对Java反射了解多少？</p>
<p><strong>候选者</strong>：嗯，Java反射在JavaSE基础中还是很重要的。</p>
<p><strong>候选者</strong>：简单来说，反射就是Java可以给我们在运行时获取类的信息</p>
<p><strong>候选者</strong>：在初学的时候可能看不懂、又或是学不太会反射，因为初学的时候往往给的例子都是用反射创建对象，用反射去获取对象上的方法/属性什么的，感觉没多大用</p>
<p><strong>候选者</strong>：但毕竟我已经不是以前的我了，跟以前的看法就不一样了。</p>
<p><strong>候选者</strong>：理解反射重点就在于理解什么是「运行时」，为什么我们要在「运行时」获取类的信息</p>
<p><strong>候选者</strong>：在当时学注解的时候，我们可以发现注解的生命周期有三个枚举值（当时我还告诉过<strong>面试官</strong>你呢~）</p>
<p><strong>候选者</strong>：分别是SOURCE、CLASS和RUNTIME，其实一样的，RUNTIME就是对标着运行时</p>
<p><strong>候选者</strong>：我们都知道：我们在编译器写的代码是 .java 文件，经过javac 编译会变成 .class 文件，class 文件会被JVM装载运行（这里就是真正运行着我们所写的代码（虽然是被编译过的），也就所谓的运行时。</p>
<p><strong>面试官</strong>：嗯，<strong>你说了那么多，就讲述了什么是运行时</strong>，还是快点进入重点吧</p>
<p><strong>候选者</strong>：在运行时获取类的信息，其实就是为了让我们所写的代码更具有「通用性」和「灵活性」</p>
<p><strong>候选者</strong>：要理解反射，需要抛开我们日常写的业务代码。以更高的维度或者说是抽象的思维去看待我们所写的“工具”</p>
<p><strong>候选者</strong>：所谓的“工具”：在单个系统使用叫做“Utils”、被多个系统使用打成jar包叫做“组件”、组件继续发展壮大就叫做“框架”</p>
<p><strong>候选者</strong>：一个好用的“工具”是需要兼容各种情况的。</p>
<p><strong>候选者</strong>：你肯定是不知道用该“工具“的用户传入的是什么对象，但你需要帮他们得到需要的结果。</p>
<p><strong>候选者</strong>：例如SpringMVC 你在方法上写上对象，传入的参数就会帮你封装到对象上</p>
<p><strong>候选者</strong>：Mybatis可以让我们只写接口，不写实现类，就可以执行SQL</p>
<p><strong>候选者</strong>：你在类上加上@Component注解，Spring就帮你创建对象</p>
<p><strong>候选者</strong>：这些统统都有反射的身影：约定大于配置，配置大于硬编码。</p>
<p><strong>候选者</strong>：通过”约定“使用姿势，使用反射在运行时获取相应的信息（毕竟作为一个”工具“是真的不知道你是怎么用的），实现代码功能的「通用性」和「灵活性」</p>
<p><strong>面试官</strong>：嗯，明白了</p>
<p><strong>面试官</strong>：结合之前说的泛型，想问下：<strong>你应该知道泛型是会擦除的，那为什么反射能获取到泛型的信息呢？</strong></p>
<p><strong>面试官</strong>：我再补充一下：泛型的信息只存在编译阶段，在class字节码就看不到泛型的信息了。那为什么下面这段代码能获取得到泛型的信息呢？</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 抽象类，定义泛型&lt;T&gt;</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">abstract</span> <span class="class"><span class="keyword">class</span> <span class="title">BaseDao</span>&lt;<span class="title">T</span>&gt; </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">BaseDao</span><span class="params">()</span></span>&#123;</span><br><span class="line">        Class clazz = <span class="keyword">this</span>.getClass();</span><br><span class="line">        ParameterizedType  pt = (ParameterizedType) clazz.getGenericSuperclass(); </span><br><span class="line">        clazz = (Class) pt.getActualTypeArguments()[<span class="number">0</span>];</span><br><span class="line">        System.out.println(clazz);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 实现类</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UserDao</span> <span class="keyword">extends</span> <span class="title">BaseDao</span>&lt;<span class="title">User</span>&gt; </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        BaseDao&lt;User&gt; userDao = <span class="keyword">new</span> UserDao();</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 执行结果输出</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">com</span>.<span class="title">entity</span>.<span class="title">User</span></span></span><br></pre></td></tr></table></figure>

<p><strong>候选者</strong>：嗯，这个问题我在学习的时候也想过</p>
<p><strong>候选者</strong>：其实是这样的，可以理解为泛型擦除是有范围的，定义在类上的泛型信息是不会被擦除的。</p>
<p><strong>候选者</strong>：Java 编译器仍在 class 文件以 Signature 属性的方式保留了泛型信息</p>
<p><strong>候选者</strong>：Type作为顶级接口，Type下还有几种类型，比如TypeVariable、ParameterizedType、WildCardType、GenericArrayType、以及Class。通过这些接口我们就可以在运行时获取泛型相关的信息。</p>
<p><strong>面试官</strong>：好，了解</p>
<p><strong>面试官</strong>：你了解动态代理吗？</p>
<p><strong>候选者</strong>：嗯，了解的。动态代理其实就是代理模式的一种，代理模式是设计模式之一。</p>
<p><strong>候选者</strong>：代理模型有静态代理和动态代理。静态代理需要自己写代理类，实现对应的接口，比较麻烦。</p>
<p><strong>候选者</strong>：在Java中，动态代理常见的又有两种实现方式：JDK动态代理和CGLIB代理</p>
<p><strong>候选者</strong>：JDK动态代理其实就是运用了反射的机制，而CGLIB代理则用的是利用ASM框架，通过修改其字节码生成子类来处理。</p>
<p><strong>候选者</strong>：JDK动态代理会帮我们实现接口的方法，通过invokeHandler对所需要的方法进行增强。</p>
<p><strong>候选者</strong>：动态代理这一技术在实际或者框架原理中是非常常见的</p>
<p><strong>候选者</strong>：像上面所讲的Mybatis不用写实现类，只写接口就可以执行SQL，又或是SpringAOP 等等好用的技术，实际上用的就是动态代理。</p>
<p><strong>面试官</strong>：嗯，了解了。</p>
<span id="more"></span>
</div>


    <div class="post-guide">
        <div class="item left">
            
              <a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/02.java%E5%B9%B6%E5%8F%91/01-%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%9F%BA%E7%A1%80/">
                  <i class="fa fa-angle-left" aria-hidden="true"></i>
                  01-多线程基础
              </a>
            
        </div>
        <div class="item right">
            
              <a href="/xinghe/2021/10/01/01.%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/01.java%E5%9F%BA%E7%A1%80/03-JavaNIO/">
                03-JavaNIO
                <i class="fa fa-angle-right" aria-hidden="true"></i>
              </a>
            
        </div>
    </div>



	<div id="vcomments"></div>


<script>
	
		// 评论
		new Valine({
			av: AV,
			el: '#vcomments',
			notify: false,
			verify: false,
			path: window.location.pathname,
			appId: 'g5woR5QAkE0rKofVTPiCqSuh-gzGzoHsz',
			appKey: 'Qbwz6GLnQv6JgX9bgtP1bdPC',
			placeholder: '请输入评论',
			avatar: 'retro',
			recordIP: false
		})
	
	
    // 显示次数
		function showTime(Counter) {
			var query = new AV.Query("Counter");
			if($(".leancloud_visitors").length > 0){
				var url = $(".leancloud_visitors").attr('id').trim();
				// where field
				query.equalTo("words", url);
				// count
				query.count().then(function (number) {
					// There are number instances of MyClass where words equals url.
					$(document.getElementById(url)).text(number?  number : '--');
				}, function (error) {
					// error is an instance of AVError.
				});
			}
		}
		// 追加pv
		function addCount(Counter) {
			var url = $(".leancloud_visitors").length > 0 ? $(".leancloud_visitors").attr('id').trim() : 'wujun234.github.io';
			var Counter = AV.Object.extend("Counter");
			var query = new Counter;
			query.save({
				words: url
			}).then(function (object) {
			})
		}
		$(function () {
			var Counter = AV.Object.extend("Counter");
			addCount(Counter);
			showTime(Counter);
		});
	
</script>
	</div>
	<div id="footer">
	<p>
	©2015-<span id="footerYear"></span> 
	<a href="/">YH</a> 
	
	
		|
		<span id="busuanzi_container_site_pv">
			本站总访问量
			<span id="busuanzi_value_site_pv"></span>次
		</span>
		|
		<span id="busuanzi_container_site_uv"> 
			有
			<span id="busuanzi_value_site_uv"></span>看过我的博客啦
		</span>
	
	<br>
	<span id="span"></span>
	</p>
</div>
<script type="text/javascript"> 
	document.getElementById('footerYear').innerHTML = new Date().getFullYear() + '';
</script>
<script type="text/javascript">
    function runtime(){
        // 初始时间，日/月/年 时:分:秒
        X = new Date("11/18/2015 0:00:00");
        Y = new Date();
        T = (Y.getTime()-X.getTime());
        M = 24*60*60*1000;
        a = T/M;
        A = Math.floor(a);
        b = (a-A)*24;
        B = Math.floor(b);
        c = (b-B)*60;
        C = Math.floor((b-B)*60);
        D = Math.floor((c-C)*60);
        //信息写入到DIV中
        span.innerHTML = "本站勉强运行: "+A+"天"+B+"小时"+C+"分"+D+"秒"
    }
    setInterval(runtime, 1000);
</script>
	<button id="totop-toggle" class="toggle"><i class="fa fa-angle-double-up" aria-hidden="true"></i></button>
</body>
</html>